package sysController

import (
	"config"
	"github.com/gin-gonic/gin"
	"net/http"
	"spirit/web/core"
)

const (
	container = "include/_container.html"
)

func Router(router *gin.Engine) {
	router.GET("/", main)
	router.POST("/menus", menus)
	router.GET("/sys/menu", menu)
	router.GET("/sys/organ", organ)
	router.GET("/sys/role", role)
}

func role(context *gin.Context) {
}

func organ(context *gin.Context) {
	/*context.HTML(http.StatusOK, "include/_container.html", gin.H{

		"Name":      "list.html",
		"Filenames": []string{"views/sys/organ/list.html"},
		"Data":      map[string]string{"name": "机构页面"},
	})*/
	core.RenderToContainerPage(context, "views/sys/organ/list.html", map[string]interface{}{
		"title": "机构页面",
	})

}

func menu(context *gin.Context) {
	core.RenderToContainerPage(context, "views/sys/menu/list.html", map[string]interface{}{
		"title": "菜单页面",
	})
}

func menus(context *gin.Context) {
	/*result := &model.BaseResult{
		Code: 0,
		Msg:  nil,
		Data: nil,
	}
	if len(config.Menus) > 0 {
		result.Msg = "成功"
		result.Data = config.Menus
	} else {
		result.Code = -1
		result.Msg = "无菜单权限"
	}*/
	context.JSON(http.StatusOK, config.Menus)
}

func main(context *gin.Context) {
	core.RenderToContainerPage(context, "main.html", map[string]interface{}{
		"title": "主界面",
	})
}
